<?php
class Article extends AppModel {

	var $name = 'Article';
	var $useDbConfig = 'rhrn';

	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $belongsTo = array(
			'User' => array('className' => 'User',
								'foreignKey' => 'user_id',
								'conditions' => '',
								'fields' => array('id', 'login'),
								'order' => ''
			),
			'Status' => array('className' => 'Status',
								'foreignKey' => 'status_id',
								'conditions' => '',
								'fields' => '',
								'order' => ''
			)
	);


	function pagianteConditions() {
		return array('limit'=>5, 'conditions'=>array($this->name . '.status_id >'=>1), 'order' => $this->name .'.id DESC');
	}

	function getTags() {
		$c = array('status_id >'=>1);
		$f = array('Article.id', 'Article.tags');
		return $this->find('list', array('conditions'=>$c, 'fields'=>$f));
	}

	function indexData() {
		return $this->find('all', array('limit'=>5, 'order'=>'Article.id DESC', 'conditions'=>array('Article.status_id >'=>1)));
	}

}
?>
